package com.enjoy.nio.client;

import com.enjoy.nio.Constant;

import java.io.IOException;
import java.util.Scanner;

public class NioClient {
    private static NioClientHandler nioClientHandler;

    public static void start() {
        nioClientHandler = new NioClientHandler(Constant.HOST, Constant.PORT);
        new Thread(nioClientHandler).start();
    }

    /*向服务器发送消息*/
    public static boolean sendMsg(String msg) throws IOException {
        nioClientHandler.sendMsg(msg);
        return true;
    }

    public static void main(String[] args) throws IOException {
        start();
        Scanner scanner = new Scanner(System.in);
        while (NioClient.sendMsg(scanner.next()));


    }
}
